package cn.customrpc.tools;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class CommonUtils {

	public static String getLocalhostIP(){
    	String ip = "";
    	InetAddress addr = null;
		try {
			addr = InetAddress.getLocalHost();
		} catch (UnknownHostException e) {
			e.printStackTrace();
		}
		if(addr != null){
			ip = addr.getHostAddress();//获得本机IP
		}else{
			ip = "127.0.0.1";
		}
		return ip;
    }
}
